<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="de.pernpas.calendar.entity.Event" %>
<%@ page import="de.pernpas.calendar.service.EventService"%>
<%@ page import="java.util.List" %>
<%@page import="de.pernpas.calendar.common.CalUtils"%>

<html>
<head>
<link type="text/css" rel="stylesheet" href="/css/stylesheet.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"">
<title>Detail</title>
</head>
<body>
	<%
	CalUtils cu = new CalUtils();
	List<Event> events = EventService.getEvents(
			Integer.parseInt(request.getParameter("day")), 
			Integer.parseInt(request.getParameter("month")),
			Integer.parseInt(request.getParameter("year")));
	
	// get the Day
	int month = Integer.parseInt(request.getParameter("month")) + 1;
	String day = request.getParameter("day") + "." + 
				month + "." + 
				request.getParameter("year") ;
	%>
	
	<div class="contentContainer marked"><%= day %></div>
	
	<%
	for(Event e: events){
	%>
		<div class="contentContainer">
			<div><span class="marked eventAttributName">Name: </span><%=e.getEventName() %></div>
			<div><span class="marked eventAttributName">Location: </span><%=e.getLocation() %></div>
			<div><span class="marked eventAttributName">Date: </span><%= cu.getDateString(e.getDate()) %></div>
			<div><span class="marked eventAttributName">Description: </span><%= e.getDescription().getValue() %></div>
			<div class="buttonContainer">
				<%
				String paramsString = "?key=" + e.getKey().getId() + 
						"&year=" + request.getParameter("year") + 
						"&month=" + request.getParameter("month") + 
						"&day=" + request.getParameter("day") + 
						"&fromPage=detail";
				%>
				<a class="button" href="/eventJSP/updateEvent.jsp<%= paramsString %>">Bearbeiten</a>
				<!-- a class="button" href="/deleteEvent<%= paramsString %>">L&ouml;schen</a-->
			</div>
		</div>
	<%
	}
	
	if(events.size() == 0){
	%>
		<div class="contentContainer">
			<div>Keine Eintr&auml;ge vorhanden.</div>
		</div>
	<%
	}
	%>
	<div class="contentContainer">
		<a class="button" href="/calendar.jsp?year=<%= request.getParameter("year")%>
				&month=<%= request.getParameter("month") %>">
			Kalender
		</a>
		<a class="button" href="/eventJSP/createEvent.jsp?year=<%= request.getParameter("year")%>
				&month=<%= request.getParameter("month")%>&day=<%= request.getParameter("day") %>
				&fromPage=detail">
			Neuen Eintrag
		</a>
	</div>
</body>
</html>